#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;
typedef struct 
{
	char oper;
	int time;
}Toper;
vector<Toper> st;
Toper op;
int top;
int n;
char ss[100009];
int p1=0;

void push()
{
	if (top < st.size()) st[top++]=op;
	else
	{
		st.push_back(op);
		top++;
	}
}
void pop()
{
	top--;
}

void trans()
{
	if (op.oper == 'm')
	{
		if (op.time%2 ==0) pop();
		else st[top-1].time = 1 ;
	}
	else
	{
		if (op.time%n == 0) pop();
		else st[top-1].time = op.time % n;
	}
}
void pretrans()
{
	if (op.oper == 'm') op.time = op.time % 2;
	else op.time = op.time % n;
}

void deal()
{
	pretrans();
	if (op.time ==0) return;
	if (top==0) push();
	else if (st[top-1].oper != op.oper) push();
	else
	{
		op.time += st[top-1].time;	
		trans();
	}
}

bool getRM()
{
	
	char *ps;
	if (p1>=strlen(ss)) return false;
	while (ss[p1]!='r' && ss[p1]!='m') p1++;
	op.oper = ss[p1];
	ps=ss+p1+1;
	sscanf(ps, "%d", &op.time);
	p1++;
	while (ss[p1]>='0' && ss[p1]<='9') p1++;
	//printf("get: %c%d\n", op.oper, op.time);
	return true;
}
void doit()
{
	top = 0;
	st.clear();
	p1 = 0;
	while (getRM())
	{
		deal();
	}
}
void output()
{
	int i;
	for (i=0; i<top-1; ++i)
		printf("%c%d ", st[i].oper, st[i].time);
	if (top>0)
	   printf("%c%d\n", st[top-1].oper, st[top-1].time);
	else printf("\n");
}
 
int main()
{
	while (1)
	{
		scanf("%d", &n);
		if (n==0) break;
		gets(ss);
		while (strlen(ss)==0) gets(ss);
		doit();
		output();
	}

	return 0;
}